#!/usr/bin/env node
'use strict'
const co = require('co')
const sugoTerminal = require('sugo-terminal')
const CLOUD_URL = 'my-sugo-cloud.example.com'
co(function * () {
let terminal = sugoTerminal(CLOUD_URL, {})
let mac = yield terminal.connect('my-mac-book-01')
let windows = yield terminal.connect('my-windows-pc-01')
let shell = mac.shell()
let kinect = windows.kinect()
kinect.on('bodyFrame', co.wrap(function * handleBodyFrame (bodyFrame) {
let { leftHand, head } = windows.kinect.helpers.parse(bodyFrame)
if (leftHand.cameraY > head.cameraY) {
let result = yield shell.exec('say', [ 'Left hands up!' ])
}
}))
kinect.start()
}).catch((err) => console.error(err))